//
//  HMStatusToolBar.m
//  HMWeiBoOC
//
//  Created by GD on 16/9/24.
//  Copyright © 2016年 geduo. All rights reserved.
//

#import "HMStatusToolBar.h"
#import "UIButton+Extension.h"
#import "UIImageView+Extension.h"

@interface HMStatusToolBar ()

@property (nonatomic,strong) UIButton *retweetButton;

@property (nonatomic,strong) UIButton *commentButton;

@property (nonatomic,strong) UIButton *unlikeButton;

@property (nonatomic,strong) UIImageView *firstLineView;

@property (nonatomic,strong) UIImageView *secondLineView;

@end

@implementation HMStatusToolBar

-(void)setStatusViewModel:(HMStatusViewModel *)statusViewModel{
    _statusViewModel = statusViewModel;
    
    [self.retweetButton setTitle:statusViewModel.retweetCountContent forState:UIControlStateNormal];
    [self.commentButton setTitle:statusViewModel.commentCountContent forState:UIControlStateNormal];
    [self.unlikeButton setTitle:statusViewModel.unlikeCountContent forState:UIControlStateNormal];
}

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{

    [self addSubview:self.retweetButton];
    [self addSubview:self.commentButton];
    [self addSubview:self.unlikeButton];
    
    [self addSubview:self.firstLineView];
    [self addSubview:self.secondLineView];
    
    [_retweetButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.equalTo(self);
        make.top.equalTo(self);
        make.bottom.equalTo(self);
        make.width.equalTo(_commentButton);
    }];
    
    [_commentButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self);
        make.leading.equalTo(_retweetButton.mas_trailing);
        make.bottom.equalTo(self);
        make.width.equalTo(_unlikeButton);

    }];
    
    [_unlikeButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(self);
        make.top.equalTo(self);
        make.bottom.equalTo(self);
        make.leading.equalTo(_commentButton.mas_trailing);
    }];
    
    [_firstLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_retweetButton.mas_trailing);
        make.centerY.equalTo(self);
    }];
    
    [_secondLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(_commentButton.mas_trailing);
        make.centerY.equalTo(self);
    }];



}

#pragma privati




#pragma mark -getter
-(UIButton *)retweetButton{
    if (!_retweetButton) {
        _retweetButton = [[UIButton alloc] initWithImageName:@"timeline_icon_retweet" title:@"转发"];
    }
    return _retweetButton;
}

-(UIButton *)commentButton{
    if (!_commentButton) {
        _commentButton = [[UIButton alloc] initWithImageName:@"timeline_icon_comment" title:@"评论"];
    }
    return _commentButton;
}

-(UIButton *)unlikeButton{
    if (!_unlikeButton) {
        _unlikeButton = [[UIButton alloc] initWithImageName:@"timeline_icon_unlike" title:@"赞"];
    }
    return _unlikeButton;
}

-(UIImageView *)firstLineView{
    if (!_firstLineView) {
        _firstLineView = [[UIImageView alloc] initWithOneLineWithImageName:nil];
    }
    return _firstLineView;
}

-(UIImageView *)secondLineView{
    if (!_secondLineView) {
        _secondLineView = [[UIImageView alloc] initWithOneLineWithImageName:nil];
    }
    return _secondLineView;
}


@end
